From 49f20887afa951b64bcd694bbe95749d0bae18ca Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Tue, 12 Feb 2008 15:58:25 +0000 Subject: [PATCH] guard against people deleting the row in question in the selection-changed 2008-02-12 Kristian Rietveld * gtk/gtktreeview.c (gtk_tree_view_real_select_cursor_row), (gtk_tree_view_real_toggle_cursor_row): guard against people deleting the row in question in the selection-changed callback. (#514621, Andreas Koehler). svn path=/trunk/; revision=19530 --- ChangeLog | 7 +++++++ gtk/gtktreeview.c | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ChangeLog b/ChangeLog index 520d1331d1..8a1d03765d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-12 Kristian Rietveld + + * gtk/gtktreeview.c (gtk_tree_view_real_select_cursor_row), + (gtk_tree_view_real_toggle_cursor_row): guard against people + deleting the row in question in the selection-changed callback. + (#514621, Andreas Koehler). + 2008-02-12 Matthias Clasen * gtk/*.c: Unify the handling of various "Enter" keysyms diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 06a4a77b22..ce67dce9c7 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -10081,6 +10081,8 @@ static gboolean gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, gboolean start_editing) { + GtkRBTree *new_tree = NULL; + GtkRBNode *new_node = NULL; GtkRBTree *cursor_tree = NULL; GtkRBNode *cursor_node = NULL; GtkTreePath *cursor_path = NULL; @@ -10126,6 +10128,15 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, mode, FALSE); + /* We bail out if the original (tree, node) don't exist anymore after + * handling the selection-changed callback. We do return TRUE because + * the key press has been handled at this point. + */ + _gtk_tree_view_find_node (tree_view, cursor_path, &new_tree, &new_node); + + if (cursor_tree != new_tree || cursor_node != new_node) + return FALSE; + gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node); gtk_widget_grab_focus (GTK_WIDGET (tree_view)); @@ -10143,6 +10154,8 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, static gboolean gtk_tree_view_real_toggle_cursor_row (GtkTreeView *tree_view) { + GtkRBTree *new_tree = NULL; + GtkRBNode *new_node = NULL; GtkRBTree *cursor_tree = NULL; GtkRBNode *cursor_node = NULL; GtkTreePath *cursor_path = NULL; @@ -10172,6 +10185,15 @@ gtk_tree_view_real_toggle_cursor_row (GtkTreeView *tree_view) GTK_TREE_SELECT_MODE_TOGGLE, FALSE); + /* We bail out if the original (tree, node) don't exist anymore after + * handling the selection-changed callback. We do return TRUE because + * the key press has been handled at this point. + */ + _gtk_tree_view_find_node (tree_view, cursor_path, &new_tree, &new_node); + + if (cursor_tree != new_tree || cursor_node != new_node) + return FALSE; + gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node); gtk_widget_grab_focus (GTK_WIDGET (tree_view)); -- 2.30.2